$(document).ready(function () {
    layui.use('form', function () {
        var form = layui.form;
        form.render();

        getUser();

    });
});

function getUser() {

    var id = $('#id').val();

    ajax(
        "/admin/user/getUser", "POST",
        { userId: id }
        ,true, true, false
    ).done(function (returnData) {

        $("input[name='userId']").val(returnData.userId);
        $("input[name='username']").val(returnData.username);
        $("input[name='password']").val(returnData.password);
        $("input[name='nickname']").val(returnData.nickname);
        $(":radio[name='sex'][value='" + returnData.sex + "']").prop("checked", true);
        $("input[name='phone']").val(returnData.phone);
        $("input[name='email']").val(returnData.email);
        $(":radio[name='status'][value='" + returnData.status + "']").prop("checked", true);
        $("textarea[name='description']").val(returnData.description);

        form.render();

    });

}

function editUser() {

    var formJSON = $("#user-submit-form").serializeObject();

    // 编辑用户
    ajax(
        "/admin/user/editUser", "POST",
        formJSON, true, true, true
    ).done(function () {
        loadingPage("/admin/user/user");
    });

}

